
export default {
  getFileIcon(filename) {
    let index = filename.lastIndexOf('.')
    let extName = filename.substr(index + 1)
    let img = ''
    try {
      img = require('@/assets/file/' +
        extName.toLowerCase() +
        '.png')
    } catch (e) {
      img = require('@/assets/file/no.png')
    }
    return img
  },
  getName(source,account){  //根据账号获取名称
    let name=''
    source.forEach(element => {
      if(element.Account == account){
        name = element.Name
      }
    });
    return name
  },
  getChatFilePath(url){  //获取聊天发送的文件路径
    if (typeof url !== 'string') {
      return ''
    }
    let urlArr=url.split('.')[0].split('_')
    let suffix = urlArr.slice(urlArr.length-1,urlArr.length)[0]
    let nameArr = urlArr.slice(0,urlArr.length-1)
    let path = window.R_config.chatNodesocket + '/static/'+suffix+'/'+nameArr.join('_')+'.'+url.split('.')[url.split('.').length-1]
    return path
  }
}